package models

import (
	"github.com/astaxie/beego/orm"
)

/*
** 化合物-靶标 共价作用关系
 */
type Relation struct {
	Id          int64
	RelationId  string `orm:"size(10);index"`
	MolId       string `orm:"size(10);index"`
	TrgId       string `orm:"size(10);index"`
	Mechanism   string `orm:"size(256)"`
	Warhead     string `orm:"size(128)"`
	Residue     string `orm:"size(256)"`
	ComplexPdb  string `orm:"size(10)"`
	RefId       string `orm:"size(10);index"`
	Description string `orm:"size(256)"`
	Action      string `orm:"size(32)"`
}

func (m *Relation) TableName() string {
	return "relation"
}

func (m *Relation) Insert() error {
	if _, err := orm.NewOrm().Insert(m); err != nil {
		return err
	}
	return nil
}

func (m *Relation) Read(fields ...string) error {
	if err := orm.NewOrm().Read(m, fields...); err != nil {
		return err
	}
	return nil
}

func (m *Relation) Update(fields ...string) error {
	if _, err := orm.NewOrm().Update(m, fields...); err != nil {
		return err
	}
	return nil
}

func (m *Relation) Delete() error {
	if _, err := orm.NewOrm().Delete(m); err != nil {
		return err
	}
	return nil
}

func (m *Relation) Query() orm.QuerySeter {
	return orm.NewOrm().QueryTable(m)
}
